-
Notifications
You must be signed in to change notification settings - Fork 877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solves #7044, refactor inner to outer for record #8197
base: master
Are you sure you want to change the base?
Conversation
see issue apache#7044 for exact problem. Start with adding tests. Introduced RECORD and RECORD_COMPONENT case labels in multiple places. Deal with method params for the record header in InnerOuterTransformer. The given way of printing the 'method parameters' for the record header include 'private final', producing illegal java code. The solution found might not be the moset elegant, but since the tree modifications will not persist into any real source code, it is acceptable. The solution strips `private` and `final` from the VARIABLE trees. Delete file threw and unnecessary exception where a simple null test suffices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did a quick pass and enabled some tests, next sync should run them.
...ring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/InnerOuterRecordTest.java
Outdated
Show resolved
Hide resolved
java/java.source.base/src/org/netbeans/modules/java/source/base/SourceLevelUtils.java
Outdated
Show resolved
Hide resolved
...oring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java
Outdated
Show resolved
Hide resolved
...oring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java
Outdated
Show resolved
Hide resolved
...oring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java
Outdated
Show resolved
Hide resolved
...actoring.java/src/org/netbeans/modules/refactoring/java/plugins/InnerToOuterTransformer.java
Outdated
Show resolved
Hide resolved
java/java.source.base/src/org/netbeans/api/java/source/TreePathHandle.java
Show resolved
Hide resolved
java/java.source.base/src/org/netbeans/modules/java/source/pretty/VeryPretty.java
Outdated
Show resolved
Hide resolved
java/java.source.base/src/org/netbeans/modules/java/source/pretty/VeryPretty.java
Show resolved
Hide resolved
...va.source.base/test/unit/src/org/netbeans/modules/java/source/save/RecordFormattingTest.java
Outdated
Show resolved
Hide resolved
java/java.source.base/src/org/netbeans/api/java/source/ElementHandle.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole file was reformatted it seems. please don't do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, muscle memory. See issue #8130.
I am trying to avoid that. but sometimes I type those keys and also do remove trailing spaces
.
But now it is done, said file now complies with the default formatting rules. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspected that this might have been unintended. But we really shouldn't do that when fixing bugs. This messes with git blame and makes it difficult to reason about repo history.
here is a commit which reverts some of the changes in unrelated code mbien@9bcdda1
its on a copy of your branch https://github.com/mbien/netbeans/tree/issue7044_copy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@homberghp may I add a commit to your branch? It appears that mbien@9bcdda1 wasn't applied, I still see large parts of InnerToOuterTransformer
reformatted in the diff https://github.com/apache/netbeans/pull/8197/files
.../refactoring.java/src/org/netbeans/modules/refactoring/java/api/InnerToOuterRefactoring.java
Outdated
Show resolved
Hide resolved
Dear mbien, thank you for your time. I just pushed to branch issue7044 on my fork. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed to branch issue7044 on my fork.
Is there anything I need to do?
thats all you have to do. Its an iterative process. The very last step before merge would be to squash as final touch - but that is for later.
Tests ran are green too - awesome. Left a few more comments.
java/java.source.base/src/org/netbeans/modules/java/source/base/SourceLevelUtils.java
Outdated
Show resolved
Hide resolved
...ring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/InnerOuterRecordTest.java
Outdated
Show resolved
Hide resolved
...oring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspected that this might have been unintended. But we really shouldn't do that when fixing bugs. This messes with git blame and makes it difficult to reason about repo history.
here is a commit which reverts some of the changes in unrelated code mbien@9bcdda1
its on a copy of your branch https://github.com/mbien/netbeans/tree/issue7044_copy
java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/DeleteFile.java
Outdated
Show resolved
Hide resolved
...actoring.java/src/org/netbeans/modules/refactoring/java/plugins/InnerToOuterTransformer.java
Outdated
Show resolved
Hide resolved
removed lines as per |
…java/test/RefactoringTestBase.java
The currentinner to outer refactoring for inner record is broken. It does not preserve a varags component. It fails in formatting the record header as it places implement clauses behind the starting brace instead of befor it.
formatting for inner record with implements still broken. Added tests. Improved pretty printer and Casual Diff to properly deal with varargs and generic parameters. Added (but disabled) test ti show broken fromatting for inner record after refactoring with record having implements clause.
Got it working for inner records for pull up and inner to outer refactoring. Formatting is (still) broken for the case that the inner record has an implements clause. |
see issue #7044 for exact problem.
Start with adding tests.
Introduced RECORD and RECORD_COMPONENT case labels in multiple places.
Deal with method params for the record header in InnerOuterTransformer. The given way of printing the 'method parameters' for the record header include 'private final', producing illegal java code. The solution found might not be the moset elegant, but since the tree modifications will not persist into any real source code, it is acceptable. The solution strips
private
andfinal
from the VARIABLE trees.Delete file threw and unnecessary exception where a simple null test
suffices.
^Add meaningful description above
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
Please make sure (eg.
git log
) that all commits have a valid name and email address for you in the Author field.If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.